package com.neugh.controller;


import com.neugh.service.AddressService;
import com.neugh.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sot
 * @since 2020-05-15
 */
@Controller

public class AddressController {

    @Autowired
    AddressService addressService;

    @Autowired
    ShopService shopService;



    @RequestMapping("orderaddress")
    public String orderaddress(Integer id, Model model){
        model.addAttribute("shopb",shopService.selectById(id));
        return "orderaddress";
    }

    /* @RequestMapping("queren2")
     public String queren2(){
         return "queren2";
     }
     */
    @RequestMapping("insertAdd")
    public String insertAdd(String address,String addressPeople,String addressPhone,Integer id,Model model){
        boolean n =  addressService.insertAddress(address,addressPeople,addressPhone);
        if(n) {
            model.addAttribute("shopa",shopService.selectById(id));
            int addressId = addressService.selectId(address,addressPeople,addressPhone);
            model.addAttribute("address",addressService.selectAddress(addressId));
            model.addAttribute("addressId",addressId);
            return  "queren2";
        }
        return "aaa";
    }

}

